package com.zyj.thread;

import java.util.concurrent.TimeUnit;

public class ThreadGroupTest {

    /**
     * 线程组：包含线程组和线程
     *      1、线程的最大优先级不能超过所在线程组的最大优先级
     *      2、线程组调用了 interrupt 方法，会递归调用其下所有线程组和线程的 interrupt 方法
     */
    public static void main(String[] args){

        ThreadGroup myThreadGroup = new ThreadGroup("MyThreadGroup");

        Thread myThread = new Thread(myThreadGroup, () -> {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "MyThread");

        myThread.start();

        System.out.println(myThread.getThreadGroup().getName());
    }

}
